package com.gs.api.projects.shejiao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gs.api.config.Constant;
import com.gs.api.projects.shejiao.entity.BalanceRecord;
import com.gs.api.projects.shejiao.dao.BalanceRecordDao;
import com.gs.api.projects.shejiao.service.IBalanceRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gs.api.projects.shejiao.vo.BalanceRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 余额记录表 服务实现类
 * </p>
 *
 * @author guoshao
 * @since 2021-10-15
 */
@Service
public class BalanceRecordServiceImpl extends ServiceImpl<BalanceRecordDao, BalanceRecord> implements IBalanceRecordService {


    @Autowired
    private BalanceRecordDao balanceRecordMapper;


    @Override
    public List<BalanceRecordVo> selectMyList(Map<String,Object> map,Integer offset) {
        Integer pageNum = 1;
        if(offset > 0){
            pageNum = (offset / Constant.PAGESIZE) + 1;
        }
        PageHelper.startPage(pageNum, Constant.PAGESIZE).setOrderBy("create_time desc");
        PageInfo<BalanceRecordVo> pageInfo = new PageInfo<>(balanceRecordMapper.selectMyList(map));
        return pageInfo.getList();
    }
}
